package com.muk.meis.model.service;

import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.muk.meis.MEISConstance.DISTRICT;
import com.muk.meis.MEISConstance.SCALE;
import com.muk.meis.model.bean.School;
import com.muk.meis.model.service.report.ReportByDistrict;
import com.muk.meis.model.service.report.ReportByOPEC;
import com.muk.meis.model.service.report.ReportByScale;
import com.muk.meis.util.XMLUtil;

public class ReportService extends BaseMEISService {
	private ReportByScale reportByScale;
	private ReportByOPEC reportByOPEC;
	private ReportByDistrict reportByDistrict;
	
	public ReportService() {
		reportByOPEC = new ReportByOPEC();
		reportByScale = new ReportByScale();
		reportByDistrict = new ReportByDistrict();
	}
	
	public Integer[] getReportByScale(SCALE scale, DISTRICT district){
		return reportByScale.getByScale(scale, district);
	}
	
	public Integer[] getReportByScaleSummary(DISTRICT district){
		return reportByScale.getByScaleSummary(district);
	}
	
	public Object[] getReportForOPEC(DISTRICT district){
		Object[] ret = (Object[])reportByOPEC.getOPECReport(district).get(0);
		return ret;
	}
	
	public Map<String, List<School>> getReportByDistrict(String districtId) {
		reportByDistrict = new ReportByDistrict();
		Map<String, List<School>> map = new LinkedHashMap<String, List<School>>();
		for (SCALE scale : EnumSet.allOf(SCALE.class)) {
			if(SCALE.S1.equals(scale)) continue;
			map.put(scale.getMessageDisplay(), reportByDistrict.getReportByDistrict(scale, districtId));
		}
		return map;
	}
	
	public String getXMLReportBySCALE(){
		XMLUtil xmlUtil = new XMLUtil();
		xmlUtil.createRoot("pie");
		
		for(SCALE scale:EnumSet.allOf(SCALE.class)){
			if(scale.isSubScale()) continue;
			//List lst = reportByScale.getByScaleXMLReport(scale);
			
		}
		
		return null;
	}
	
	public static void main(String[] args) {
		ReportService service = new ReportService();
		Map<String, List<School>> map = service.getReportByDistrict("1");
		System.out.println();
	}

}
